home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sun4c
/
archive
/
tcltk.z
/
tcltk
/
man
/
cat3
/
EnterFile.3
< prev
next >
Wrap
Text File
|
1994-09-20
|
5KB
|
133 lines
Tcl_EnterFile(3) Tcl Library Procedures 7.0
_________________________________________________________________
NAME
Tcl_EnterFile, Tcl_GetOpenFile, Tcl_FilePermissions - mani-
pulate the table of open files
SYNOPSIS
#include <tcl.h>
Tcl_EnterFile(_i_n_t_e_r_p, _f_i_l_e, _p_e_r_m_i_s_s_i_o_n_s)
int
Tcl_GetOpenFile(_i_n_t_e_r_p, _s_t_r_i_n_g, _w_r_i_t_e, _c_h_e_c_k_U_s_a_g_e, _f_i_l_e_P_t_r)
int
Tcl_FilePermissions(_f_i_l_e)
ARGUMENTS
Tcl_Interp *_i_n_t_e_r_p (in) Tcl interpreter from
which file is to be
accessed.
FILE *_f_i_l_e (in) Handle for file that is
to become accessible in
_i_n_t_e_r_p.
int _p_e_r_m_i_s_s_i_o_n_s (in) OR-ed combination of
TCL_FILE_READABLE and
TCL_FILE_WRITABLE; indi-
cates whether _f_i_l_e was
opened for reading or
writing or both.
char *_s_t_r_i_n_g (in) String identifying file,
such as stdin or file4.
int _w_r_i_t_e (in) Non-zero means the file
will be used for writ-
ing, zero means it will
be used for reading.
int _c_h_e_c_k_U_s_a_g_e (in) If non-zero, then an
error will be generated
if the file wasn't
opened for the access
indicated by _w_r_i_t_e.
FILE **_f_i_l_e_P_t_r (out) Points to word in which
to store pointer to FILE
structure for the file
given by _s_t_r_i_n_g.
_________________________________________________________________
Tcl 1
Tcl_EnterFile(3) Tcl Library Procedures 7.0
DESCRIPTION
These procedures provide access to Tcl's file naming mechan-
ism. Tcl_EnterFile enters an open file into Tcl's file
table so that it can be accessed using Tcl commands like
gets, puts, seek, and close. It returns in _i_n_t_e_r_p->_r_e_s_u_l_t
an identifier such as file4 that can be used to refer to the
file in subsequent Tcl commands. Tcl_EnterFile is typically
used to implement new Tcl commands that open sockets, pipes,
or other kinds of files not already supported by the built-
in commands.
Tcl_GetOpenFile takes as argument a file identifier of the
form returned by the open command or Tcl_EnterFile and
returns at *_f_i_l_e_P_t_r a pointer to the FILE structure for the
file. The _w_r_i_t_e argument indicates whether the FILE pointer
will be used for reading or writing. In some cases, such as
a file that connects to a pipeline of subprocesses, dif-
ferent FILE pointers will be returned for reading and writ-
ing. Tcl_GetOpenFile normally returns TCL_OK. If an error
occurs in Tcl_GetOpenFile (e.g. _s_t_r_i_n_g didn't make any sense
or _c_h_e_c_k_U_s_a_g_e was set and the file wasn't opened for the
access specified by _w_r_i_t_e) then TCL_ERROR is returned and
_i_n_t_e_r_p->_r_e_s_u_l_t will contain an error message. If _c_h_e_c_k_U_s_a_g_e
is zero and the file wasn't opened for the access specified
by _w_r_i_t_e, then the FILE pointer returned at *_f_i_l_e_P_t_r may not
correspond to _w_r_i_t_e.
Tcl_FilePermissions returns an OR-ed combination of the mask
bits TCL_FILE_READABLE and TCL_FILE_WRITABLE; these indicate
whether the given file was opened for reading or writing or
both. If _f_i_l_e does not refer to a file in Tcl's file table
then -1 is returned.
KEYWORDS
file table, permissions, pipeline, read, write
Tcl 2